package com.ruoyi.web.controller.drinkwater;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.drinkwater.domain.BusWaterSegmentWaterIntake;
import com.ruoyi.drinkwater.service.IBusWaterSegmentWaterIntakeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 水源地取水口Controller
 * 
 * @author ruoyi
 * @date 2025-08-26
 */
@RestController
@RequestMapping("/drink/intake")
public class BusWaterSegmentWaterIntakeController extends BaseController
{
    @Autowired
    private IBusWaterSegmentWaterIntakeService busWaterSegmentWaterIntakeService;

    /**
     * 查询水源地取水口列表
     */
//    @PreAuthorize("@ss.hasPermi('system:INTAKE:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusWaterSegmentWaterIntake busWaterSegmentWaterIntake)
    {
        startPage();
        List<BusWaterSegmentWaterIntake> list = busWaterSegmentWaterIntakeService.selectBusWaterSegmentWaterIntakeList(busWaterSegmentWaterIntake);
        return getDataTable(list);
    }

    /**
     * 导出水源地取水口列表
     */
//    @PreAuthorize("@ss.hasPermi('system:INTAKE:export')")
//    @Log(title = "水源地取水口", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusWaterSegmentWaterIntake busWaterSegmentWaterIntake)
    {
        List<BusWaterSegmentWaterIntake> list = busWaterSegmentWaterIntakeService.selectBusWaterSegmentWaterIntakeList(busWaterSegmentWaterIntake);
        ExcelUtil<BusWaterSegmentWaterIntake> util = new ExcelUtil<BusWaterSegmentWaterIntake>(BusWaterSegmentWaterIntake.class);
        util.exportExcel(response, list, "水源地取水口数据");
    }

    /**
     * 获取水源地取水口详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:INTAKE:query')")
    @GetMapping( "/getInfo/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(busWaterSegmentWaterIntakeService.selectBusWaterSegmentWaterIntakeById(id));
    }

    /**
     * 新增水源地取水口
     */
//    @PreAuthorize("@ss.hasPermi('system:INTAKE:add')")
//    @Log(title = "水源地取水口", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody BusWaterSegmentWaterIntake busWaterSegmentWaterIntake)
    {
        return toAjax(busWaterSegmentWaterIntakeService.insertBusWaterSegmentWaterIntake(busWaterSegmentWaterIntake));
    }

    /**
     * 修改水源地取水口
     */
//    @PreAuthorize("@ss.hasPermi('system:INTAKE:edit')")
//    @Log(title = "水源地取水口", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody BusWaterSegmentWaterIntake busWaterSegmentWaterIntake)
    {
        return toAjax(busWaterSegmentWaterIntakeService.updateBusWaterSegmentWaterIntake(busWaterSegmentWaterIntake));
    }

    /**
     * 删除水源地取水口
     */
//    @PreAuthorize("@ss.hasPermi('system:INTAKE:remove')")
//    @Log(title = "水源地取水口", businessType = BusinessType.DELETE)
	@GetMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(busWaterSegmentWaterIntakeService.deleteBusWaterSegmentWaterIntakeByIds(ids));
    }
}
